import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class InsertServlet extends HttpServlet{
	/**
	 * @author ajam
	 *@values are inserted in this method
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
	{
		String str1=req.getParameter("laptop");
		System.out.println("str1"+str1);
		String str2=req.getParameter("cost");
		System.out.println("str2"+str2);
		//String str3=req.getParameter("cost");
		
		//int pcost=Integer.parseInt(str3.trim());
		
		HibernateDao hd=new HibernateDao();
		boolean b=hd.insert(str1, str2);
		res.setContentType("text/html");
		PrintWriter pw=res.getWriter();
		if(b==true)
		{
			pw.println("<h1>record are inserted</h1>");
		}
		else
		{
			pw.println("<h1>failed to insert</h1>");
			pw.println("<a href='profile.html'>HOME</a>");
		}pw.println("<a href='profile.html'>HOME</a>");
	}
	}
